package test.ground.monitor;

import com.wang.tool.monitor.aop.Monitor;
import com.wang.tool.monitor.core.MonitorInfo;
import com.wang.tool.monitor.weaver.MonitorWeaver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Random;

/**
 * @Author wangshaopeng
 * @Date 2022/7/2
 */
@Service
public class ServiceB {

    @Autowired
    private ServiceA serviceA;

    @Monitor(group = "ServiceB")
    public String hi() {
        System.out.println("ServiceB");
        try {
            Thread.sleep(60);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        String key = String.valueOf(new Random().nextInt());
        serviceA.hi(key);
        return key;
    }

    public static class B implements MonitorWeaver<Void> {
        @Override
        public void weaveOnBefore(MonitorInfo<Void> monitorInfo) {

        }

        @Override
        public void weaveOnAfter(MonitorInfo<Void> monitorInfo) {
            monitorInfo.setStatus("11这是stat");
            monitorInfo.addDigest("nam1","diges1");
            monitorInfo.addDetail("params",monitorInfo.getParams());


        }
    }


}
